<template>
    <div class="main_mapContainer">
        <!-- 地图容器 -->
        <div ref="mapContainer" id="mapContainer" class="map-container"></div>
        <!-- 时间轴 -->
        <!-- <timeAxisControl :startTime="0" :endTime="3600" :initialTime="0" :duration="3600" class="timeAxisControl" /> -->
        <!-- FPS帧率监测 -->
        <!-- <FPS></FPS> -->
        <!-- 鼠标移动显示经纬度 -->
        <!-- <div id="mouse-position"></div> -->
        <legends style="position:absolute;right: 50%;transform: translateX(50%); bottom: 8px;z-index: 300;width: 50%;"></legends>
        <layers class="changeTile"></layers>
    </div>

</template>

<script setup lang="ts">
import { defineComponent, getCurrentInstance, onMounted, ref } from "vue";
// 主处理类库
import OpenLayersMap from "./OpenLayersMap";

import timeAxisControl from "./mapComponent/controls/timeAxisControl.vue";// 引入时间组件
import FPS from "./mapComponent/controls/FPS.vue";  // FPS组件
import layers from "./mapComponent/controls/layers.vue";
import legends from "./mapComponent/controls/legend.vue";
import GeoTIFF from 'ol//source/GeoTIFF';
import test from "./mapComponent/layers/grayMapColor";
import TileLayer from "ol/layer/Tile";


const mapContainer = ref<HTMLElement | null>(null);
let map;
let olService = OpenLayersMap.getInstance()
const value = ref(true)


// 引用地图上的其他组件
onMounted(() => {

    methods.init_cme_base2D()
})
const methods = {
    tileChangeHandle: (val) => {
        if (val === true) {
            olService.changeBaseMap('T_Vector')
        } else {
            olService.changeBaseMap('T_Image')
        }
    },
    /**
     *  创建地图实体
     */
    init_cme_base2D: () => {
        if (mapContainer.value) {
            // 初始化
            map = olService.initMap(mapContainer.value, { center: [120.616, 36.44], zoom: 9.5 })
        }
    }
}

</script>

<style lang="less" scoped>
.main_mapContainer {
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    //border: 1px solid red;
    position: relative;

    .map-container {
        width: 100%;
        height: 100%;
        position: absolute;
        left: 0px;
        top: 0px;
        z-index: 2;
    }

    .timeAxisControl {
        position: absolute;
        right: 10px;
        bottom: 10px;
        z-index: 3;
        // border:1px solid red;
    }

    .changeTile {
        position: absolute;
        right: 30px;
        bottom: 130px;
        z-index: 3;
    }

    #mouse-position {
        position: absolute;
        width: 180px;
        height: 40px;
        bottom: 5px;
        left: 45%;
        background-color: rgba(0, 0, 0, 0.2);
        z-index: 3;
        color: white;
        display: flex;
        align-items: center;
        justify-content: center
    }
}



:deep(.modal-content) {

    h4,
    p {
        margin: 0;
        padding: 0;
        line-height: 30px;
    }

    h4 {
        line-height: 50px;
    }

    background-color: #fff;
    padding: 15px;
    box-sizing: border-box;
    border: 1px solid #888;
    width: 300px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);

    .close {
        color: #aaa;
        float: right;
        font-size: 28px;
        font-weight: bold;
    }

    .close:hover,
    .close:focus {
        color: black;
        text-decoration: none;
        cursor: pointer;
    }
}

:deep(.homeworkBox) {
    background-color: #ffffffb5;
    padding: 15px;
    border-radius: 5px;
    position: relative;

    &::before {
        position: absolute;
        content: "";
        width: 0;
        height: 0;
        border-bottom: 10px solid transparent;
        border-right: 10px solid transparent;
        border-top: 10px solid #ffffffb5;
        border-left: 10px solid transparent;
        bottom: -20px;
        left: 50%;
        transform: translateX(-50%);
    }

    .homeworkInformation {
        display: flex;
        min-width: 550px;
        height: 100%;
        font-size: 15px;
        /* background-color: #f5f5f5; */
    }

    .left {
        min-width: 50%;
        height: 100%;
        /* background-color: #ccc; */
    }

    .right {
    }

    .homeworkInformation {
        display: flex;
        min-width: 550px;
        height: 100%;
        font-size: 15px;
        /* background-color: #f5f5f5; */
    }

    .left {
        min-width: 50%;
        height: 100%;
        /* background-color: #ccc; */
    }

    .right {
        min-width: 50%;
        height: 100%;
    }

    .td {
        display: flex;
    }

    .td div {
        padding: 10px 3px;
        box-sizing: border-box;
        border: 1px solid #ccc;
    }

    .td div:first-child {
        width: 40%;
        text-align: right;
        background-color: #f8f8f8;
    }

    .td div:last-child {
        width: 60%;
        height: 45px;
        overflow: auto;

        /* 滚动条样式 */
        &::-webkit-scrollbar {
            width: 8px;
        }

        /* 滑块样式 */
        &::-webkit-scrollbar-thumb {
            border-radius: 10px;
        }

        /* 滚动条轨道样式 */
        &::-webkit-scrollbar-track {
            border-radius: 10px;
        }
    }

    .footerTr {
        width: 550px;
        font-size: 15px;
    }

    .footerTr div:first-child {
        width: 20%;
        text-align: right;
        background-color: #f8f8f8;
    }

    .footerTr div:last-child {
        width: 80%;
    }

    .footer {
        width: 550px;
        margin: 10px 0 0 0;
        text-align: center;
    }

    button {
        margin: 0 5px;
        padding: 5px;
        border: none;
        border-radius: 5px;
        background-color: #007bff;
        color: white;
        cursor: pointer;
        transition: background-color 0.3s;
    }

    button:hover {
        background-color: #0056b3;
    }
}
</style>